#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>
using namespace std;

class Solution
{
public:
    int Number(vector<int>& v,int m)
    {
        int size = 0;
        for (int i = 2;i < m;++i)
        {
            size += v[i];
        }
        
        return size;
    }

    vector<string> letterCombinations(string digits)
    {
        string s1("abcdefghijklmnopqrstuvwxyz");
        vector<int> mem({ 0,0,3,3,3,3,3,4,3,4 });
        int size = 1;
        for (auto& e : digits)
        {
            size *= mem[e - '0'];
        }

        vector<string> ret(size);
        ret.resize(size);

        for (int i = 0; i < size; ++i)
        {
            for (int j = 0; j < digits.size(); ++j)
            {
                int x = Number(mem,j);
                for (int l = x - j; l < x; ++l)
                {
                    ret[i] += s1[l];
                }
            }
        }

        return ret;
    }
};

int main()
{
    Solution s1;
    string ss("23");
    vector<string> v = s1.letterCombinations(ss);
    for (auto& e : v)
    {
        cout << e << endl;
    }

    return 0;
}